package com.cloud.pole.shop.biz.order;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Options;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear;
import com.cloud.pole.common.biz.BaseBiz;
import com.cloud.pole.mapper.goods.ShopGoodsSpecMapper;
import com.cloud.pole.mapper.order.ShopOrderShoppingCartMapper;
import com.cloud.pole.shop.model.entity.goods.ShopGoodsSpec;
import com.cloud.pole.shop.model.entity.order.ShopOrderShoppingCart;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

/**
 * ${DESCRIPTION}
 *
 * @author wanghaobin
 * @create 2017-06-08 16:23
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ShopOrderShoppingCartBiz extends BaseBiz<ShopOrderShoppingCartMapper, ShopOrderShoppingCart> {
	
	@Override 
    @CacheClear(pre="shopOrderShoppingCartList{1.userId}")
	public void insertSelective(ShopOrderShoppingCart shopOrderShoppingCart) {
		super.insertSelective(shopOrderShoppingCart);
	}
	
	@Override 
    @CacheClear(pre="shopOrderShoppingCartList{1.userId}")
	public void updateSelectiveById(ShopOrderShoppingCart shopOrderShoppingCart) {
		super.updateSelectiveById(shopOrderShoppingCart);
	}
	
	@Override 
	@CacheClear(pre="shopOrderShoppingCartList{1.userId}")
	public void delete(ShopOrderShoppingCart msg) {
		super.delete(msg);
    }
	
	@Cache(key="shopOrderShoppingCartList{1}")
	public List<ShopOrderShoppingCart> selectListByUserId(Long userId){
		 Example example = new Example(ShopOrderShoppingCart.class);
		 Criteria criteria = example.createCriteria();
         example.setOrderByClause("cart_id desc");
		 criteria.andEqualTo("userId", userId);
		 return selectByExample(example);
	}
}
